﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Common;
using DAL;
using Model;
namespace UI.system
{
    public partial class index : BaseAdmin
    {
        public AdminInfo admin = new AdminInfo();
        public ConfigInfo config = new ConfigInfo();
        public List<MenuInfo> menulist = new List<MenuInfo>();
        public List<MenuInfo> parentlist = new List<MenuInfo>();
        
        protected void Page_Load(object sender, EventArgs e)
        {
            AdminInfo info = B.MyAdmin;
            admin = AdminDAL.FindOneByID(info.ID);
            config = ConfigDAL.FindOneByID(1);
            menulist = MenuDAL.FindAllOfShow();
            //如果是超级管理员，则拥有所有权限
            if (info.ID != 1)
            {
                string[] power = info.Power.Split(',');
                menulist = menulist.Where(x => power.Contains("menu-" + x.ID)).ToList();
            }
            parentlist = menulist.Where(x => x.ParentID == 0).ToList();
        }
    }
}